import { _decorator } from 'cc';
import { BaseView } from '../../../scripts/libs/rxjs/cc3/BaseView';
import { find } from 'cc';
import { ParticleSystem2D } from 'cc';
import { Timer } from '../../../scripts/libs/rxjs/cc3/CreatorSchedule';
import { Subscription } from 'rxjs';
import { nullifySubscription } from '../../../scripts/libs/rxjs/utils';
import { ResourceHelper } from '../../scripts/ResourceHelper';
const { ccclass, property } = _decorator;

@ccclass('Burst2')
export class Burst2 extends BaseView {

    onDestroyView(): void {
        nullifySubscription.call(this, '_sub');
    }
    _sub: Subscription = null;
    burst() {
        nullifySubscription.call(this, '_sub');
        let ps2d = find('dot', this.node).getComponent(ParticleSystem2D);
        ps2d.resetSystem();
        this._sub = Timer(1, this.node).subscribe(_ => {
            ResourceHelper.Burst2Pool.putNode(this.node);
        });
    }
}

